#include <linux/module.h>
#include <linux/fs.h>
#include <linux/errno.h>
#include <linux/miscdevice.h>
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/mutex.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/stat.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/tty.h>
#include <linux/kmod.h>
#include <linux/gfp.h>
#include <asm/io.h>
#include "led_board.h"


static volatile unsigned int *CCM_CCGR1;
static volatile unsigned int *IOMUX_SW_MUX_CTL_PAD_GPIO1_IO03;
static volatile unsigned int *GPIO1_GDIR;
static volatile unsigned int *GPIO1_DR;


void led_board_init(void){
    CCM_CCGR1 = ioremap(0x20C406C, 4);
    IOMUX_SW_MUX_CTL_PAD_GPIO1_IO03 = ioremap(0x20E0068, 4);
    GPIO1_GDIR = ioremap(0x0209C004, 4);
    GPIO1_DR = ioremap(0x0209C000,4);

    *CCM_CCGR1 |= (3<<26);//使能时钟
    *IOMUX_SW_MUX_CTL_PAD_GPIO1_IO03 &= ~(0xF);//GPIO模式
    *IOMUX_SW_MUX_CTL_PAD_GPIO1_IO03 |= 5;
    *GPIO1_GDIR |= (1<<3);//输出模式
}

void led_board_ctrl(char status){
    if(status)
    {
        *GPIO1_DR &= ~(1<<3);//低电平亮
    }
    else{
        *GPIO1_DR |= (1<<3);//高电平灭
    }
}
